<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<table border="1">
    <caption>员工信息</caption>
    <tr>
        <td>id</td><td>姓名</td><td>工资</td><td>工作</td><td>操作</td>
    </tr>
    <tr v-for="emp in arr">
        <td>{{emp.id}}</td>
        <td>{{emp.name}}</td>
        <td>{{emp.sal}}</td>
        <td>{{emp.job}}</td>
        <td>
            <a :href="'/update.html?id='+emp.id">修改</a>
            <a href="javascript.void(0)" @click="del(emp.id)">删除</a></td>
    </tr>
</table>

<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"table",
        data:{
            arr:[],
        },
        created:function (){
            axios.get("/select").then(function (response){
                v.arr = response.data;
            })
        },
        methods:{
            del(id){
                if(confirm("您确认删除此员工吗")){
                    axios.get("/delete?id="+id).then(function (response){
                        location.reload();
                    })
                }

            }
        }
    })
</script>
</body>
</html>